<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-09 13:34:01
 * @Last Modified time: 2022-12-23 16:34:55
 */
namespace app\common\dao\store;

use frank\base\BaseDao;
use app\common\model\store\ShippingTemplatesModel;

/**
 * Class ShippingTemplatesDao
 * @package app\common\dao\store
 */
class ShippingTemplatesDao extends BaseDao
{
    /**
     * 设置模型名
     */
    protected function setModel(): string
    {
        return ShippingTemplatesModel::class;
    }

    public function getDetail($filter)
    {
        if(is_array($filter)){
            return $this->search($filter)->with(['citys','free_citys'])->find();
        }else{
            return $this->search(['id'=>$filter])->with(['citys','free_citys'])->find();
        }
    }


    /**
     * 列表
     */
    public function getShippingTemplatesList(array $where = [], int $page, int $limit)
    {
        return $this->search($where)->order('sort DESC,id DESC')->page($page)->paginate($limit)->toArray();
    }
    
    /**
     * 列表
     */
    public function getShippingTemplatesSelect(array $where = [])
    {
        return $this->search($where)->order('sort DESC,id DESC')->select()->toArray();
    }
    
}